<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/views/include/adminHead.jsp" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<LINK href="${cssUrl}/admin.css" rel="stylesheet" type="text/css">
  <TR>
    <TD height="%" valign="top">
      <TABLE width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">
        <TBODY>
        <TR>
          <TD width="186" height="%" align="right" valign="top"><!-- Left Menu table 시작 --------------------------------> 
                        
            <TABLE width="176" height="100%" border="0" cellspacing="0" 
            cellpadding="0">
              <TBODY>
              <TR>
                <TD height="53"><IMG 
              src="${imgUrl}/left_top_title.gif"></TD></TR>
              <TR>
                <TD height="%" background="${imgUrl}/left_bg.gif" valign="top" 
                style="padding: 5px 0px 0px 5px;"> <!-- Menu table 끝 * css사용 해당메뉴의 페이지일때는  class="leftmenu_b", 해당 메뉴페이지가 아닐경우  class="leftmenu"로 사용--------------------------------> 
                  <TABLE width="150" style="margin-top: 10px;" border="0" 
                  cellspacing="0" cellpadding="0">
                    <TBODY>
					<c:forEach var = "menu" items="${menuList}">					
						<tr>
							<td height="25"><img src="${imgUrl}/left_icon.gif" border="0" align="absmiddle"/>
								<a class="leftmenu" href="javascript:goAdminBoardListMain(<c:out value="${menu.menuIndex}" />, <c:out value="${menu.menuType}" />)"><c:out value="${menu.menuName}" /></a>
							</td>
						</tr>				
					</c:forEach>
					<tr>
						<td height="25"><img src="${imgUrl}/left_icon.gif" border="0" align="absmiddle"/><a class="leftmenu" href="javascript:goAdminMenuList();">&nbsp;메뉴관리</a></td>
					</tr>
						</TBODY></TABLE></TD></TR></TBODY></TABLE><!-- Left Menu table 끝 --------------------------------> 
                    </TD>
          <TD width="%" align="right" valign="top" style="padding: 20px 10px 0px 0px;">
            <TABLE width="97%" border="0" cellspacing="0" cellpadding="0">
              <TBODY>
              <TR>
                <TD align="left" class="admin_title" background="${imgUrl}/title_bg.gif" 
                valign="middle"><IMG align="absmiddle" src="${imgUrl}/title_icon.gif"><c:out value="${menu.menuName}" /></TD></TR>
              <TR>
                <TD height="20">&nbsp;</TD></TR>
              <TR>
                <TD>
                  <TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
                    <TBODY>
                    <TR>
                      <TD colspan="2"><!--리스트 테이블 시작-->                       
                        <TABLE width="100%" bgcolor="#d9d9d9" border="0" 
                        cellspacing="1" cellpadding="0">
                          <TBODY>
                          <TR>
                            <TD height="1" bgcolor="#3f8bc9" colspan="4"></TD></TR>
                          <TR>
                            <TD align="left" class="top_blue3" style="padding-left: 10px;" 
                            bgcolor="#eff3fa" colspan="6"><c:out value="${boardView.title}" />
                                </TD></TR>
                          <TR>
                            <TD width="15%" height="30" align="left" style="padding-left: 10px;" 
                            bgcolor="#ffffff"><STRONG>작성일 : 
                              </STRONG></TD>
                            <TD width="15%" align="left" style="padding-left: 10px;" 
                            bgcolor="#ffffff"><fmt:formatDate value="${boardView.regiTime}" pattern="yyyy-MM-dd HH:mm:ss"/> 		</TD>
                            <TD width="15%" align="left" style="padding-left: 10px;" 
                            bgcolor="#ffffff"><STRONG>첨부파일 :</STRONG></TD>
                            <TD width="30%" align="left" style="padding-left: 10px;" 
                            bgcolor="#ffffff"> <a href = "/board/download?menuIndex=${menu.menuIndex}&textID=${textID}"> <c:out value="${boardView.attachment}" /></a></TD>
                            <TD width="15%" align="left" style="padding-left: 10px;" 
                            bgcolor="#ffffff"><STRONG>조회수 :</STRONG></TD>
                            <TD width="10%" align="left" style="padding-left: 10px;" 
                            bgcolor="#ffffff"><STRONG><c:out value="${boardView.viewCnt}" /></STRONG></TD></TR>
						<tr>
							<TD width="%" height="30" align="left" style="padding-left: 10px;" bgcolor="#ffffff"><STRONG>구매포인트 : </STRONG></TD>
							<TD width="%" height="30" align="left" style="padding-left: 10px;" bgcolor="#ffffff"><c:out value="${boardView.usePoint}" /></TD>
							<TD width="%" height="30" align="left" style="padding-left: 10px;" bgcolor="#ffffff"><STRONG>누적포인트 : </STRONG></TD>
							<TD width="%" height="30" align="left" style="padding-left: 10px;" bgcolor="#ffffff" colspan="3"><c:out value="${boardView.sumPoint}" /></TD>
						</tr>
						<tr>
							<TD width="%" height="30" align="left" style="padding-left: 10px;" bgcolor="#ffffff"><STRONG>정보제공자 : </STRONG></TD>
							<TD width="%" height="30" align="left" style="padding-left: 10px;" bgcolor="#ffffff" colspan="5">
								<table width="100%">
								<c:forEach var="result" items="${provider}" varStatus="status">
									<tr>
										<td height="20"><c:out value="${result.providerName}" /> <c:out value="${result.providerAddress}" /></td>
									</tr>
								</c:forEach>
								</table>
							</TD>
						</tr>
                          <TR>
                            <TD style="padding: 10px;" bgcolor="#ffffff" colspan="6">
                            	<c:out value="${boardView.contents}" escapeXml="false" />
                            	
							</TD>
						</TR></TBODY></TABLE><!--리스트 테이블 끝--> 
                       </TD></TR>
                    <TR>
                      <TD align="left"><IMG src="${imgUrl}/btn_list.gif" border="0" onClick="goBoardList();" style="cursor:hand;"></TD>
                      <TD height="35" align="right">
                      	<IMG src="${imgUrl}/btn_modify.gif" border="0" onClick="adminBoardWrite(2)" style="cursor:hand;">
                        <IMG src="${imgUrl}/btn_del.gif" border="0" hspace="3" onClick="deleteAdminBoard();" style="cursor:hand;"> 
                        <IMG src="${imgUrl}/btn_write.gif" border="0" onClick="adminBoardWrite(1);" style="cursor:hand;">
                    </TD>
                  	</TR>
                </TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
<form style="display:none;"id="frm" name="frm" method="post">
	<input type="hidden" name="menuIndex" id="menuIndex" value="${menu.menuIndex}">
	<input type="hidden" name="menuType" id="menuType" value="${menu.menuType}">
	<input type="hidden" name="textID" id="paramTextID" value="${textID}">
	<input type="hidden" name="attachment" id="attachment" value="<c:out value="${boardView.attachment}" />">
	<input type="hidden" name="attachmentPath" id="attachmentPath" value="<c:out value="${boardView.attachmentPath}" />">
	<input type="hidden" name="imgAttachment" id="imgAttachment" value="<c:out value="${boardView.imgAttachment}" />">
	<input type="hidden" name="imgAttachmentPath" id="imgAttachmentPath" value="<c:out value="${boardView.imgAttachmentPath}" />">
	<input type="hidden" name="mode" id="mode">
</form> 

<script type="text/javascript">
function goAdminBoardListMain(type, menuType) {
		// type = 1 공지사항
		// type = 2 최신판례
		// type = 3 최신법령
		// type = 4 A항목
		// type = 5 B항목
		// type = 6 C항목
		// type = 7 D항목
		// type = 8 E항목
		// type = 9 F항목
		// type = 10 G항목
		// type = 11 H항목
		$("#menuIndex").val(type);
		$("#menuType").val(menuType);
		var url;
		
		if (menuType == 0) {
			url = "/admin/adminBoardMain";	
		} else {
			url = "/admin/adminBoard2Main";
		}
					
		$("#frm").attr("action", url);
		$("#frm").submit();
		
  }
  
  function deleteAdminBoard() {
	  
	  if(confirm("삭제하시겠습니까?")) {
		  var url='deleteAdminBoard.json';
		  var param = "textID="+$("#paramTextID").val();
		  AjaxPost(url, param, function(data){
			  alert(data.msg);
			  goAdminBoardListMain($("#menuIndex").val());
		  });
	  } else {
		  return;
	  }
  }
  
  function adminBoardWrite(type) {
	//type = 1 글쓰기
	//type = 2 수정
	if(type == 1) {
		$("#mode").val("insert");
	} else {
		$("#mode").val("modify");
	}
  	$("#frm").attr("action", "/admin/adminBoardWrite");
  	$("#frm").submit();
  }
  
  function goBoardList() {
	  var type = $("#menuIndex").val();
	  var menuType = $("#menuType").val();
	  goAdminBoardListMain(type, menuType);
  }
  function fileDownload() {
	var param = "fileName="+$("#attachmentPath").val()+"&originalFileName="+$("#attachment").val();
	location.href= "/admin/download?"+param;
  }
  
  var goAdminMenuList = function(){
		location.replace("/admin/adminMenuMain");
	};
</script>

                 </BODY></HTML>
